
<!doctype html>
<html lang="zh" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      
        <link rel="prev" href="../latex/">
      
      
      
      <link rel="icon" href="../../assets/images/favicon.png">
      <meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.4.14">
    
    
      
        <title>哈工深测试 - 测试站点 | UPC-FPLab</title>
      
    
    
      <link rel="stylesheet" href="../../assets/stylesheets/main.fad675c6.min.css">
      
        
        <link rel="stylesheet" href="../../assets/stylesheets/palette.356b1318.min.css">
      
      


    
    
      
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
    <script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
    
  </head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="deep-purple" data-md-color-accent="deep-purple">
  
    
    
      <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#1" class="md-skip">
          跳转至
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

<header class="md-header" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="页眉">
    <a href="../.." title="测试站点 | UPC-FPLab" class="md-header__button md-logo" aria-label="测试站点 | UPC-FPLab" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M176 24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40c-35.3 0-64 28.7-64 64H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40v56H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40v56H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40c0 35.3 28.7 64 64 64v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40h56v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40h56v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40c35.3 0 64-28.7 64-64h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40v-56h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40v-56h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40c0-35.3-28.7-64-64-64V24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40h-56V24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40h-56V24zm-16 104h192c17.7 0 32 14.3 32 32v192c0 17.7-14.3 32-32 32H160c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32zm192 32H160v192h192V160z"/></svg>

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            测试站点 | UPC-FPLab
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              哈工深测试
            
          </span>
        </div>
      </div>
    </div>
    
      
        <form class="md-header__option" data-md-component="palette">
  
    
    
    
    <input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="deep-purple" data-md-color-accent="deep-purple"  aria-label="切换到夜晚模式"  type="radio" name="__palette" id="__palette_1">
    
      <label class="md-header__button md-icon" title="切换到夜晚模式" for="__palette_2" hidden>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5c-.84 0-1.65.15-2.39.42L12 2M3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29L3.34 7m.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14L3.36 17M20.65 7l-1.77 3.79a7.023 7.023 0 0 0-2.38-4.15l4.15.36m-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29L20.64 17M12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44L12 22Z"/></svg>
      </label>
    
  
    
    
    
    <input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="deep-purple" data-md-color-accent="deep-purple"  aria-label="切换到白天模式"  type="radio" name="__palette" id="__palette_2">
    
      <label class="md-header__button md-icon" title="切换到白天模式" for="__palette_1" hidden>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3 3.19.09m3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95 2.06.05m-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31Z"/></svg>
      </label>
    
  
</form>
      
    
    
    
      <label class="md-header__button md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="查找">
        
        <button type="reset" class="md-search__icon md-icon" title="清空当前内容" aria-label="清空当前内容" tabindex="-1">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            正在初始化搜索引擎
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
      <div class="md-header__source">
        <a href="https://gitee.com/upc-cs-fplab/testground" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
  </div>
  <div class="md-source__repository">
    upc-cs-fplab/testground
  </div>
</a>
      </div>
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
            
<nav class="md-tabs" aria-label="标签" data-md-component="tabs">
  <div class="md-grid">
    <ul class="md-tabs__list">
      
        
  
  
    
  
  
    
    
      <li class="md-tabs__item md-tabs__item--active">
        <a href="../.." class="md-tabs__link">
          
  
  首页

        </a>
      </li>
    
  

      
    </ul>
  </div>
</nav>
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    


  


<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="导航栏" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../.." title="测试站点 | UPC-FPLab" class="md-nav__button md-logo" aria-label="测试站点 | UPC-FPLab" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M176 24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40c-35.3 0-64 28.7-64 64H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40v56H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40v56H24c-13.3 0-24 10.7-24 24s10.7 24 24 24h40c0 35.3 28.7 64 64 64v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40h56v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40h56v40c0 13.3 10.7 24 24 24s24-10.7 24-24v-40c35.3 0 64-28.7 64-64h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40v-56h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40v-56h40c13.3 0 24-10.7 24-24s-10.7-24-24-24h-40c0-35.3-28.7-64-64-64V24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40h-56V24c0-13.3-10.7-24-24-24s-24 10.7-24 24v40h-56V24zm-16 104h192c17.7 0 32 14.3 32 32v192c0 17.7-14.3 32-32 32H160c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32zm192 32H160v192h192V160z"/></svg>

    </a>
    测试站点 | UPC-FPLab
  </label>
  
    <div class="md-nav__source">
      <a href="https://gitee.com/upc-cs-fplab/testground" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
  </div>
  <div class="md-source__repository">
    upc-cs-fplab/testground
  </div>
</a>
    </div>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
  
  
    
  
  
  
    
    
    
    
    
      
      
    
    <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
      
        
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_1" checked>
        
          
          <label class="md-nav__link" for="__nav_1" id="__nav_1_label" tabindex="">
            
  
  <span class="md-ellipsis">
    首页
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_1_label" aria-expanded="true">
          <label class="md-nav__title" for="__nav_1">
            <span class="md-nav__icon md-icon"></span>
            首页
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../.." class="md-nav__link">
        
  
  <span class="md-ellipsis">
    MkDocs README
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../md/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    MD语法测试
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../latex/" class="md-nav__link">
        
  
  <span class="md-ellipsis">
    latex支持测试
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  <span class="md-ellipsis">
    哈工深测试
  </span>
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        
  
  <span class="md-ellipsis">
    哈工深测试
  </span>
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#1" class="md-nav__link">
    <span class="md-ellipsis">
      1. 实验目的
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#2-for-minirv" class="md-nav__link">
    <span class="md-ellipsis">
      2. 实验内容 (for miniRV)
    </span>
  </a>
  
    <nav class="md-nav" aria-label="2. 实验内容 (for miniRV)">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1_1" class="md-nav__link">
    <span class="md-ellipsis">
      题目1：基本输入输出
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2" class="md-nav__link">
    <span class="md-ellipsis">
      题目2：简易计算器设计
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#2a-for-minila" class="md-nav__link">
    <span class="md-ellipsis">
      2A. 实验内容 (for miniLA)
    </span>
  </a>
  
    <nav class="md-nav" aria-label="2A. 实验内容 (for miniLA)">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1_2" class="md-nav__link">
    <span class="md-ellipsis">
      题目1：基本输入输出
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2_1" class="md-nav__link">
    <span class="md-ellipsis">
      题目2：简易计算器设计
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#1" class="md-nav__link">
    <span class="md-ellipsis">
      1. 实验目的
    </span>
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#2-for-minirv" class="md-nav__link">
    <span class="md-ellipsis">
      2. 实验内容 (for miniRV)
    </span>
  </a>
  
    <nav class="md-nav" aria-label="2. 实验内容 (for miniRV)">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1_1" class="md-nav__link">
    <span class="md-ellipsis">
      题目1：基本输入输出
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2" class="md-nav__link">
    <span class="md-ellipsis">
      题目2：简易计算器设计
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#2a-for-minila" class="md-nav__link">
    <span class="md-ellipsis">
      2A. 实验内容 (for miniLA)
    </span>
  </a>
  
    <nav class="md-nav" aria-label="2A. 实验内容 (for miniLA)">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1_2" class="md-nav__link">
    <span class="md-ellipsis">
      题目1：基本输入输出
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2_1" class="md-nav__link">
    <span class="md-ellipsis">
      题目2：简易计算器设计
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  


  <h1>哈工深测试</h1>

<h2 id="1">1. 实验目的</h2>
<p>&emsp;&emsp;（1）进一步熟悉RARS、Logisim等汇编和模拟仿真工具的使用；</p>
<p>&emsp;&emsp;（2）熟练掌握RISC-V汇编语言，熟悉并理解RISC-V指令系统；</p>
<p>&emsp;&emsp;（3）了解程序在单周期RISC-V CPU搭建的SoC中的运行过程。</p>
<h2 id="2-for-minirv">2. 实验内容 (for miniRV)</h2>
<h3 id="1_1">题目1：基本输入输出</h3>
<p>&emsp;&emsp;在提供的Logisim环境中，运行提供的程序<font color = blue><strong>Exercise1.asm</strong></font>，并阅读该程序源码，分析程序功能，学习汇编程序如何访问I/O接口及外设。</p>
<p>&emsp;&emsp;数码管、LED、拨码开关的端口地址如表1-1所示。</p>
<p><center>表1-1 数码管、LED、拨码开关端口地址</center>
<center></p>
<table>
<thead>
<tr>
<th style="text-align: center;">外设</th>
<th style="text-align: center;">基址</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">数码管</td>
<td style="text-align: center;">0xFFFF_F000</td>
</tr>
<tr>
<td style="text-align: center;">LED</td>
<td style="text-align: center;">0xFFFF_F060</td>
</tr>
<tr>
<td style="text-align: center;">拨码开关</td>
<td style="text-align: center;">0xFFFF_F070</td>
</tr>
</tbody>
</table>
<p></center></p>
<p>&emsp;&emsp;根据实验步骤运行程序，熟悉Logisim工具及操作流程。</p>
<h3 id="2">题目2：简易计算器设计</h3>
<p>&emsp;&emsp;运用miniRV指令集编写汇编程序，实现简易计算器。计算器是输入、输出都是8bit的数据。</p>
<p>&emsp;&emsp;计算器执行<u>逻辑运算</u>时，需将输入的操作数A和B视为 <mark>无符号数</mark>；执行<u>其他运算</u>时，需将输入的操作数A和B视为 <mark>有符号数</mark> 。</p>
<div class="admonition danger">
<p class="admonition-title">注意 <img alt="💣" class="twemoji" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/1f4a3.svg" title=":bomb:" /></p>
<p>&emsp;&emsp;计算器程序最终需要下板运行和演示，因此 <strong>禁止使用除miniRV指令集以外的其他指令</strong>。</p>
<p>&emsp;&emsp;如果后续设计CPU时，只实现24条必做指令，则编写本题目时不要使用附加的13条指令。</p>
</div>
<p>&emsp;&emsp;计算器的运算符和操作数A、B均通过拨码开关输入，如表1-2所示。</p>
<p><center>表1-2 8位简易计算器的拨码开关输入定义</center>
<center></p>
<table>
<thead>
<tr>
<th style="text-align: center;">拨码开关</th>
<th style="text-align: center;">SW[23:21]</th>
<th style="text-align: center;">SW[20:16]</th>
<th style="text-align: center;">SW[15:8]</th>
<th style="text-align: center;">SW[7:0]</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">输入功能</td>
<td style="text-align: center;">运算符</td>
<td style="text-align: center;">保留</td>
<td style="text-align: center;">操作数A</td>
<td style="text-align: center;">操作数B</td>
</tr>
</tbody>
</table>
<p></center></p>
<p>&emsp;&emsp;计算器的运算结果需显示到数码管DK7~DK0。具体地，计算器的功能如表1-3所示。</p>
<p><center>表1-3 运算器功能定义</center>
<center></p>
<table>
<thead>
<tr>
<th style="text-align: center;">SW[23:21]</th>
<th style="text-align: center;">运算类型</th>
<th style="text-align: center;">数码管显示内容</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">3'b000</td>
<td style="text-align: center;">A &amp; B</td>
<td style="text-align: center;">运算结果以2进制显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b001</td>
<td style="text-align: center;">A | B</td>
<td style="text-align: center;">运算结果以2进制显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b010</td>
<td style="text-align: center;">A ^ B</td>
<td style="text-align: center;">运算结果以2进制显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b011</td>
<td style="text-align: center;">A &lt;&lt; B</td>
<td style="text-align: center;">运算结果以有符号整数显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b100</td>
<td style="text-align: center;">A &gt;&gt; B (算术右移)</td>
<td style="text-align: center;">运算结果以有符号整数显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b101</td>
<td style="text-align: center;">(A == 0) ? B : [B]<sub>补</sub></td>
<td style="text-align: center;">运算结果以2进制显示</td>
</tr>
<tr>
<td style="text-align: center;">3'b110</td>
<td style="text-align: center;">A <script type="math/tex">\div</script> B</td>
<td style="text-align: center;">除法的 <strong>商</strong> 以有符号整数显示</td>
</tr>
</tbody>
</table>
<p></center></p>
<div class="admonition tip">
<p class="admonition-title">提示 <img alt="💡" class="twemoji" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/1f4a1.svg" title=":bulb:" /></p>
<p>&emsp;&emsp;除法可使用《计算机组成原理》中的恢复余数法或加减交替法等算法来实现。<br />
&emsp;&emsp;PPT回顾：<br />
<embed src = "https://docs.qq.com/pdf/DZGF2cXhWUEhPdklk#page=50" width="100%" height="500"></p>
<p>&emsp;&emsp;以上两种算法也适用于整数除法，注意试商是从被除数最高位开始的。符号位单独处理，取除数和被除数的绝对值进行运算。<br />
&emsp;&emsp;设被除数<script type="math/tex">x</script> = +<code>1101B</code>，除数<script type="math/tex">y</script> = -<code>0110B</code>；<script type="math/tex">x</script>的绝对值<script type="math/tex">x^*</script> = <code>01101B</code>，<script type="math/tex">y</script>的绝对值<script type="math/tex">y^*</script> = <code>00110B</code>，<script type="math/tex">y^*</script>的补码<script type="math/tex">[-y^*]_补</script> = <code>11010B</code>，则有：  </p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">恢复余数法</label><label for="__tabbed_1_2">加减交替法</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<p>&emsp;&emsp;令被除数减去<script type="math/tex">y^*</script>，即加上<script type="math/tex">[-y^*]_补</script>：<br />
&emsp;&emsp;<strong>·</strong> 若得到的余数为负数，表明不够减，故商上0，并加上<script type="math/tex">y^*</script>以恢复余数，然后被除数左移1位，再加上<script type="math/tex">[-y^*]_补</script>；<br />
&emsp;&emsp;<strong>·</strong> 若得到的余数为正数，表明够减，故商上1，令被除数左移1位，再加上<script type="math/tex">[-y^*]_补</script>；<br />
&emsp;&emsp;重复以上步骤N次，N为位宽。在本例中，N = 4。
<center><img src = "../assets/div_rr.png" width = 64%></center></p>
</div>
<div class="tabbed-block">
<p>&emsp;&emsp;令被除数减去<script type="math/tex">y^*</script>，即加上<script type="math/tex">[-y^*]_补</script>：<br />
&emsp;&emsp;<strong>·</strong> 若得到的余数为负数，表明不够减，故商上0，令被除数左移1位，再加上<script type="math/tex">[y]_补</script>；<br />
&emsp;&emsp;<strong>·</strong> 若得到的余数为正数，表明够减，故商上1，令被除数左移1位，再加上<script type="math/tex">[-y^*]_补</script>；<br />
&emsp;&emsp;重复以上步骤N次，N为位宽。在本例中，N = 4。
<center><img src = "../assets/div_as.png" width = 64%></center></p>
</div>
</div>
</div>
</div>
<h2 id="2a-for-minila">2A. 实验内容 (for miniLA)</h2>
<h3 id="1_2">题目1：基本输入输出</h3>
<p>&emsp;&emsp;在提供的LoongArchAssembler汇编及模拟工具中，运行提供的程序<font color = blue><strong>Exercise1A.asm</strong></font>，并阅读该程序源码，分析程序功能，学习汇编程序如何访问I/O接口及外设。</p>
<p>&emsp;&emsp;数码管、LED、拨码开关的端口地址同表1-1。</p>
<p>&emsp;&emsp;阅读LoongArchAssembler简介文档，熟悉汇编及模拟工具的操作流程。</p>
<h3 id="2_1">题目2：简易计算器设计</h3>
<p>&emsp;&emsp;题目内容与miniRV的类似，但有以下不同：</p>
<p>&emsp;&emsp;（1）只能使用miniLA指令集中的指令实现计算器；如果后续设计CPU时，只实现25条必做指令，则编写本题目时不要使用附加的13条指令；</p>
<p>&emsp;&emsp;（2）使用提供的汇编程序模板<code>calculator.asm</code>完成汇编实验。在模板程序中，输入数据提前存放在数据段中，运算结果也写入到数据段中 (具体地址自定)，如图1-1所示。<ins>将来下板时，将获取输入数据的地址改成拨码开关的I/O地址、将保存运算结果的地址改成数码管的I/O地址即可</ins>。</p>
<p><div class="highlight"><pre><span></span><code><span class="w"> </span><span class="err">1|</span><span class="na">.data</span>
<span class="w"> </span><span class="err">2|</span><span class="w">    </span><span class="nl">test0:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0x00f624</span><span class="w">    </span><span class="c1"># test0: SW[23:21]==3&#39;b000, A==8&#39;hf6, B==8&#39;h24</span>
<span class="w"> </span><span class="err">3|</span><span class="w">    </span><span class="nl">test1:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0x201430</span><span class="w">    </span><span class="c1"># test1: SW[23:21]==3&#39;b001, A==8&#39;h14, B==8&#39;h30</span>
<span class="w"> </span><span class="err">4|</span><span class="w">    </span><span class="nl">test2:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0x401213</span><span class="w">    </span><span class="c1"># test2: SW[23:21]==3&#39;b010, A==8&#39;h12, B==8&#39;h13</span>
<span class="w"> </span><span class="err">5|</span><span class="w">    </span><span class="nl">test3:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0x608812</span><span class="w">    </span><span class="c1"># test3: SW[23:21]==3&#39;b011, A==-120,  B==18</span>
<span class="w"> </span><span class="err">6|</span><span class="w">    </span><span class="nl">test4:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0x8023f4</span><span class="w">    </span><span class="c1"># test4: SW[23:21]==3&#39;b100, A==35,    B==-12</span>
<span class="w"> </span><span class="err">7|</span><span class="w">    </span><span class="nl">test5:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0xa000fa</span><span class="w">    </span><span class="c1"># test5: SW[23:21]==3&#39;b101, A==0,     B==-6</span>
<span class="w"> </span><span class="err">8|</span><span class="w">    </span><span class="nl">test6:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0xa001ef</span><span class="w">    </span><span class="c1"># test6: SW[23:21]==3&#39;b101, A==1,     B==-17</span>
<span class="w"> </span><span class="err">9|</span><span class="w">    </span><span class="nl">test7:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0xc0f102</span><span class="w">    </span><span class="c1"># test7: SW[23:21]==3&#39;b110, A==-15,   B==2</span>
<span class="err">10|</span><span class="w">    </span><span class="nl">test8:</span><span class="w"> </span><span class="na">.word</span><span class="w"> </span><span class="mi">0xc0eefc</span><span class="w">    </span><span class="c1"># test8: SW[23:21]==3&#39;b110, A==-18,   B==-4</span>
<span class="err">11|</span>
<span class="err">12|</span><span class="na">.text</span>
<span class="err">13|</span><span class="nl">MAIN:</span>
<span class="err">14|</span><span class="w">    </span><span class="c1"># TODO</span>
</code></pre></div>
<center>图1-1 <code>calculator.asm</code>模板代码节选片段</center></p>





                
              </article>
            </div>
          
          
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
    <div class="md-copyright__highlight">
      Copyright &copy; 2023 - Now 中国石油大学（华东）
    </div>
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    
    <script id="__config" type="application/json">{"base": "../..", "features": ["navigation.tabs", "navigation.expand"], "search": "../../assets/javascripts/workers/search.f886a092.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
    
    
      <script src="../../assets/javascripts/bundle.cd18aaf1.min.js"></script>
      
        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>
      
    
  </body>
</html>